//
//  HomeViewController.m
//  RedHareCar
//
//  Created by WDL on 16/12/20.
//  Copyright © 2016年 CarCredit. All rights reserved.
//

#import "HomeViewController.h"
/** 轮播图*/
#import "SDCycleScrollView.h"
/** 首页视图*/
#import "HomeTableViewCell.h"
/** <#变量说明#>*/

@interface HomeViewController ()<SDCycleScrollViewDelegate>


@property(nonatomic,weak) SDCycleScrollView *cycleScrollView;

@property(nonatomic,strong) UIView *headerContainerView;

@property (weak, nonatomic) IBOutlet UITableView *tableView;


@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"首页";
    self.view.backgroundColor = OrangeColor;
    [self createTableHeader];



}



- (void)createTableHeader{
    
    UIView *headerContainerView = [[UIView alloc]init];
    headerContainerView.backgroundColor = UIColorFromRGB(0xf5f5f5);
    headerContainerView.backgroundColor = OrangeColor;
    headerContainerView.frame = CGRectMake(0, 0, Screen_Width, 188);
    self.headerContainerView = headerContainerView;
    //网络加载 --- 创建带标题的图片轮播器
    SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageURLStringsGroup:nil];
    cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    cycleScrollView.backgroundColor = OrangeColor;
    cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
    cycleScrollView.delegate = self;
    cycleScrollView.dotColor = UIColorFromRGB(0xD8D8D8); // 自定义分页控件小圆标颜色
    cycleScrollView.placeholderImage = [UIImage imageNamed:@"placeholder"];
    [headerContainerView addSubview:cycleScrollView];
    [cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        //在 父试 图中 上边的距离
        make.top.mas_equalTo(0);
        //在父试图中 左边 右
        make.leading.mas_equalTo(0);
        make.trailing.mas_equalTo(0);
        make.height.mas_equalTo(188);
    }];
    self.cycleScrollView = cycleScrollView;
    self.tableView.tableHeaderView = self.headerContainerView;
    
}

#pragma mark - SDCycleScrollViewDelegate 轮播图上点击 对应的图片
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", index);
    
    
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollIndeAtCurrentIndex:(NSInteger)index{
    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 10;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  
        return 194;
}
/**
 *  绘制cell
 *
 */
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
        HomeTableViewCell *cell = [HomeTableViewCell cellWithTabelView:tableView];
        return cell;
  
}




@end
